package com.imedical.strategy;

import com.imedical.enums.SendRequestEnum;

import java.util.Map;

import cn.hutool.core.map.MapUtil;
import cn.hutool.extra.spring.SpringUtil;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2022/1/19
 */
public class SendRequestFactory {

    private static final Map<SendRequestEnum, SendRequestStrategy> STRATEGY_MAP = MapUtil.newHashMap();

    static {
        STRATEGY_MAP.put(SendRequestEnum.HTTP, SpringUtil.getBean(SendHttpRequestStrategy.class));
        STRATEGY_MAP.put(SendRequestEnum.FTP, SpringUtil.getBean(SendFtpRequestStrategy.class));
        STRATEGY_MAP.put(SendRequestEnum.WebService, SpringUtil.getBean(SendWebServiceRequestStrategy.class));
    }

    private SendRequestFactory() {
    }

    public static SendRequestStrategy getStrategy(SendRequestEnum sendRequestEnum) {
        return STRATEGY_MAP.get(sendRequestEnum);
    }
}
